{extend name="base" /}
{block name="cont"}
<style>
    .layui-table img {
        max-width: 100%;
    }
    #pages .layui-laypage-em{
        background-color: #f40002!important;
    }
</style>
{notempty name="list_base.add"}
<a href="{$list_base.add}" title="{$list_base.title|default=''}" class="cx-button ll-bg-red cx-text-white">{in name='list_base.add' value='/member/forms.article/create.html?fid=1'}申请志愿者{else/}{$list_base.addtitle|default="发布"}{$list_base.title|default=""}{/in}</a>
{/notempty}
<table class="layui-table" lay-skin="line">
    <thead>
    <tr>
        {volist name=":WormCms('filed@FiledsToTable',$list_file)" id="cx" empty=""}
        <th class="{$cx.class|default=''}" style="{notempty name='cx.width'}width: {$cx.width}px;{else /}min-width: 60px;{/notempty}">{$cx.title}</th>
        {/volist}
    </tr>
    </thead>
    <tbody>
    {volist name="listdb.data" id="cx" empty=""}
    <tr>
        {volist name=":WormCms('filed@FiledsToTable',$list_file,$cx)" id="c" empty=""}
        <td>
            {if $c.type == 'imgsee'}
            <div class="cx-bg-img1x1 cx-bor">
                <div class="cx-bg-img cx-fex-c cx-fex-itemsc">
                    {empty name="c.value"}<img src="__PUBLIC__/img/imgnone.jpg" alt="" style="width: 100%;">{else /}{$c.value|raw}{/empty}
                </div>
            </div>
            {else /}
            {$c.value|raw}
            {/if}
        </td>
        {/volist}
    </tr>
    {/volist}
    </tbody>
</table>
<div id="pages" class="layout cx-fex-c cx-pad-a20 cx-page"></div>
{// 检测是否需要分页 }
{notempty name="listdb.total"}
<script>
    layui.use('laypage', function(){
        var laypage = layui.laypage,
            getUrlPapram = function (name) {
                let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"),
                    r = window.location.search.substr(1).match(reg); //匹配目标参数
                if (r != null) return unescape(r[2]);
                return null;
            };
        //执行一个laypage实例
        laypage.render({
            elem: 'pages',
            count: "{$listdb.total}",
            limit: "{$listdb.per_page}",
            limits:['20','50','100'],
            curr:  "{$listdb.current_page}",
            jump: function(obj, first){
                let url = window.location.href;
                if(url.indexOf('page=') > 0){
                    let v = getUrlPapram('page');
                    url = v != null ? url.replace(`page=${v}`,`page=${obj.curr}`) : url.replace(`page=`,`page=${obj.curr}`);
                }else{
                    url = url.indexOf("?") > 0 ? url + `&page=${obj.curr}` : url + `?page=${obj.curr}`;
                }
                if(!first){
                    window.location.href = url;
                }
            }
        });
    });
</script>
{/notempty}
{/block}
